#ifndef __ATL_KRNL_KMM__
#define __ATL_KRNL_KMM__
#include <cstdint.h>
#include <string.h>
#include "pmm.h"
/* The kernel heap's initial and pre paging sizes are 3M */
#define KMM_START_HEAP		0x300000 
#define KMM_FREE_FLAG		1 << 0
#define KMM_EOM_FLAG		1 << 1
/* Grow size is 100K to assure theres enough space for a pagetable and
 * page directory when the heap is too small during page mapping. */
#define KMM_GROW_SIZE		0x10000
#define KMM_MIN_BLOCK_SIZE	4
typedef struct kmm_heap {
	uint32_t start_ptr;
	uint32_t free_ptr;
} kmm_heap_t;

typedef struct kmm_block_hdr {
	uint8_t flags;
	physical_addr phys;
	uint32_t next_ptr;
	uint32_t prev_ptr;//For a CPU effective kmm_block_merge() 
					  //implementation, as in most modern PC's
	                  //memory is more abundant than CPU time.
} kmm_block_hdr_t;

void kmm_setup_heap(kmm_heap_t *heap, void *base_ptr, size_t initial_size, physical_addr page);
void *kmalloc(size_t size);
void *kmalloc_ap(size_t size,physical_addr *phys);
void kfree(void *ptr);

#endif